package edu.suda.xsap.service.impl;
import edu.suda.xsap.dto.CustomerStatsDto;
import edu.suda.xsap.dto.convert.CustomerStatsConvert;
import edu.suda.xsap.entity.CustomerStats;
import edu.suda.xsap.mapper.CustomerStatsMapper;
import edu.suda.xsap.service.CustomerStatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.Month;
import java.time.Year;
import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerStatsServiceImpl implements CustomerStatsService {
    @Autowired
    private CustomerStatsConvert customerStatsConvert;

    @Autowired
    private CustomerStatsMapper customerStatsMapper;

    @Override
    public List<CustomerStatsDto> searchNewByYear(Year year1, Year year2) {
        List<CustomerStats> customerStatss = customerStatsMapper.searchNewByYear(year1,year2);
        return customerStatsConvert.toDtoList(customerStatss);
    }
    @Override
    public List<CustomerStatsDto> searchNewByYearAndMonth(Year year, Month month) {
        List<CustomerStats> customerStatss = customerStatsMapper.searchNewByYearAndMonth(year,month);
        return customerStatsConvert.toDtoList(customerStatss);
    }
    @Override
    public List<CustomerStatsDto> searchNewByYearAndQuarter(Year year) {
        List<CustomerStats> customerStatss = customerStatsMapper.searchNewByYearAndQuarter(year);
        return customerStatsConvert.toDtoList(customerStatss);
    }

    @Override
    public List<CustomerStatsDto> searchNewByMonth(Year year) {
        List<CustomerStats> customerStatss = customerStatsMapper.searchNewByMonth(year);
        return customerStatsConvert.toDtoList(customerStatss);
    }

}
